From: Florian Müllner Date: Wed, 12 Jul 2023 22:25:43 +0000 (+0200) Subject: lookingGlass: Handle unprintable object X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~337^2~1^2~153 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=03025d7cff68800507ac14766f99ad54c247bb3e;p=gnome-shell.git lookingGlass: Handle unprintable object We currently throw an error when encountering a result that cannot be represented as string, with the prompt appearing somewhat stuck (the input cannot be committed). Showing a lame fallback instead at least avoids that issue. When the object has a typeof 'object' but is not an instanceof Object, we are likely dealing with an ES module, and can show a slightly less lame fallback. Part-of: --- diff --git a/js/ui/lookingGlass.js b/js/ui/lookingGlass.js index 6063b1740..05006d837 100644 --- a/js/ui/lookingGlass.js +++ b/js/ui/lookingGlass.js @@ -268,6 +268,11 @@ function objectToString(o) { if (typeof o == typeof objectToString) { // special case this since the default is way, way too verbose return ''; + } else if (o && o.toString === undefined) { + // eeks, something unprintable. we'll have to guess, probably a module + return typeof o === 'object' && !(o instanceof Object) + ? '' + : ''; } else { return `${o}`; }